package jutf8search;

import java.util.Vector;
/**
 * The interface for the exact searching algorithms, such as Boyer-Moore, Knuth-Morris-Pratt
 *
 */
public interface ExactSearchInterface
{
    /**
     * Build the search table for the algorithm using a byte[].
     * @param query The query
     */
	public void buildTable(byte[] query) throws Exception;
	
    /**
     * Build the search table for the algorithm using a String.
     * 
     * @param query The query to be searched for.
     * 
     * @throws Exception If there was a problem building the table
     * (usually that the query length was too short for the specified algorithm)
     */
	public void buildTable(String query) throws Exception;
	
	/**
	 * Counts the occurences of a pattern in the byte[] text. Returns them as a long.
	 * 
	 * @param text The byte[] to search
	 * @return A long representing the number of matches found.
	 * 
	 */
	public long numMatches(byte[] text);
	
	/**
	 * Runs the algorithm and returns the position of the matchNumth match.
	 * 
	 * @param text The byte[] to be searched
	 * @param matchNum The number match to return.
	 * @return A long representing the position in the byte[] where the match
	 * 		   was found. If there is no match it will return -1.
	 */
	public long matchNum(byte[] text, long matchNum);

    /**
     * Returns a Vector of byte positions of each match
     *
     * @param text The text to search
     * @return Vector of results
     */
    public Vector<Long> fullSearch(byte[] text);
	
	/**
	 * Get the size of the pattern being searched for
	 * @return Size of the pattern 
	 */
	public int getPatternSize();

    /**
     * Reset the match valve, used to record how many matches there have been over several
     * iterations of the search on different chunks.
     */
	public void resetMatch();
}
